﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using RooHui.Infrastructure.Entities.EFContext;
using RooHui.Infrastructure.Entities.Repository;
using RooHui.Infrastructure.Entities.Enum;

namespace RooHui.Infrastructure.Entities.Entity
{
    public class GuaranteeCompany : IAccessible<P_GuaranteeCompany, GuaranteeCompany>, ILogicEntity<P_GuaranteeCompany, GuaranteeCompany>
    {
        public int ID { get; set; }
        public string CompanyName { get; set; }
        public string LogoImage { get; set; }
        public string Summary { get; set; }
        public string Description { get; set; }
        public string QualificationsImages { get; set; }
        public string AgreementImages { get; set; }
        public ItemStatus Status { get; set; }
        public string CreateUser { get; set; }
        public DateTime CreateTime { get; set; }

        protected override void Covariant(P_GuaranteeCompany model)
        {
            if (model != null)
            {
                this.AgreementImages = model.AgreementImages;
                this.CompanyName = model.CompanyName;
                this.CreateTime = model.CreateTime;
                this.CreateUser = model.CreateUser;
                this.Description = model.Description;
                this.ID = model.ID;
                this.LogoImage = model.LogoImage;
                this.QualificationsImages = model.QualificationsImages;
                this.Status = (ItemStatus)model.Status;
                this.Summary = model.Summary;
            }
        }

        protected override P_GuaranteeCompany Inverter(GuaranteeCompany model)
        {
            if (model != null)
            {
                return new P_GuaranteeCompany()
                {
                    AgreementImages = model.AgreementImages,
                    CompanyName = model.CompanyName,
                    CreateTime = model.CreateTime,
                    CreateUser = model.CreateUser,
                    Description = model.Description,
                    ID = model.ID,
                    LogoImage = model.LogoImage,
                    QualificationsImages = model.QualificationsImages,
                    Status = (int)model.Status,
                    Summary = model.Summary
                };
            }
            return null;
        }

        public GuaranteeCompany Set(P_GuaranteeCompany dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
